#include "dispatcherservlet.h"
#include "loger.h"
#include <QUrl>
DispatcherServlet::DispatcherServlet(QObject *parent) : Servlet (parent)
{

}
DispatcherServlet::~DispatcherServlet(){
    QString info("DispatcherServlet已析构");
    Loger::info(info);
}

void DispatcherServlet::doService(HttpRequest * request, HttpResponse *response){
//    QString paramName  = "name";
//    QString userName = request->getParameter(paramName);
//    userName  = QUrl::fromPercentEncoding(userName.toUtf8());
//    QString info("用户名:");
//    info.append(userName);
//    Loger::info(info);
    QString name = "Content-Type";
    QString value = "text/json;charset=UTF-8";

    response->addHeader(name, value);
    QString body("{\"name\":\"denglibin\"}");
    QByteArray  arr = body.toUtf8().data();
    response->write(&arr, body.length());
}
